<template>
  <div>
    <CommonCard title="今日销售额" :count="salesToday">
      <!-- 这里是父组件 给CommonCard传递结构-->
      <!-- 插槽是在组件中使用的 -->
      <template #main>
        <div class="main">
          <div class="item">
            <div>日同比</div>
            <div class="count">{{ salesGrowthLastDay }}</div>
            <div :class="{up:salesGrowthLastDay>0 ,down:salesGrowthLastDay<0}"></div>
          </div>
          <div class="item">
            <div>月同比</div>
            <div class="count">{{ salesGrowthLastMonth }}</div>
            <div :class="{up:salesGrowthLastMonth>0,down:salesGrowthLastMonth<0}"></div>
          </div>
        </div>
      </template>
      <template #bottom>
        <span>昨日销售额</span>
        <span class="left">{{ salesLastDay }}</span>
      </template>

    </CommonCard>

  </div>
</template>

<script lang="ts">
import { defineComponent } from "vue"
export default defineComponent({
  name: 'TodaySale',
})
</script>

<script lang="ts" setup>
import { useEchartsStore } from '@/stores/echarts'
import { computed } from 'vue'
// 定义一个变量
const echartsStore = useEchartsStore()
// salesToday:30346799
// salesLastDay:36000000
// salesGrowthLastDay:-19.16
// salesGrowthLastMonth:56.67

// 获取数据
const salesToday = computed(() => {
  return echartsStore.echartsData.salesToday
})
const salesLastDay = computed(() => {
  return echartsStore.echartsData.salesLastDay
})
const salesGrowthLastDay = computed(() => {
  return echartsStore.echartsData.salesGrowthLastDay
})
const salesGrowthLastMonth = computed(() => {
  return echartsStore.echartsData.salesGrowthLastMonth
})
</script>

<style lang="scss" scoped>
.main {
  height: 50px;
  color: #ccc;
  display: flex;
  // 设置主轴的方法  从上到下排列
  flex-direction: column;
  justify-content:space-around;
   .item {
    display: flex;
    font-size: 12px;
    font-weight: 600;
    color: #aaa;
    // 定义flex子项在flex容器的当前行的纵轴，center位于容器的中心
    align-items: center;
    .count {
      margin: 0 5px
    }
    // .up{
    //   border:5px solid red;
    //   border-left-color: transparent;
    //   border-right-color: transparent;
    //   border-top-color: transparent;
    // }
    // .down{
    //   border:5px solid blue;
    //   border-left-color: transparent;
    //   border-right-color: transparent;
    //   border-bottom-color: transparent;
    // }
  }
  // .left{
  //   margin-left:20px
  // }
}
</style>